home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / APW.SC / SC16Aware / Menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-24  |  3.6 KB  |  116 lines  |  [TEXT/pdos]

  1. /*
  2.     Menus.c -- Version 3.0 
  3.  
  4.     Developer Technical Support Apple II Sample Code
  5.  
  6.     Copyright (c) 1990 by Apple Computer, Inc.
  7.     All Rights Reserved.
  8.  
  9.     This file contains the code to set up and handle
  10.     the menus used in the network aware sample program.
  11. */
  12.  
  13. #include <IntMath.h>                        /* {CIIGSIncludes}IntMath.h */
  14. #include <Window.h>                         /* {CIIGSIncludes}Window.h */
  15. #include <Menu.h>                           /* {CIIGSIncludes}Menu.h */
  16. #include <Desk.h>                           /* {CIIGSIncludes}Desk.h */
  17. #include "Aware.h"
  18.  
  19. /* Declare the global variables so we can use them in these routines */
  20. extern int quitFlag;
  21. extern WmTaskRec event;
  22. extern char asciiTime[];
  23.  
  24.  
  25.  
  26. /*
  27.     setupMenus()
  28.     
  29.     This routine creates the system menu bar, complete with
  30.     desk accessories, and draws it.
  31. */
  32. void setupMenus()
  33. {
  34.     /* Create the system menu bar from a resource */
  35.     SetSysBar(NewMenuBar2(refIsResource, 0x0001L, NULL));
  36.     SetMenuBar(NULL);                       /* Current menu bar is system menu bar */
  37.     
  38.     FixAppleMenu(AppleMenuID);              /* Add DAs to apple menu. */
  39.  
  40.     FixMenuBar();                           /* Set sizes of menus. */
  41.     
  42.     DrawMenuBar();                          /* Put the menu bar up */
  43. }
  44.  
  45.  
  46.  
  47. /*
  48.     doQuitItem()
  49.  
  50.     Handles the Quit menu item by setting the flag to quit and
  51.     saving configuration data.
  52. */
  53. void doQuitItem()
  54. {
  55.     saveConfig();                           /* Save configuration data on exit */
  56.     quitFlag++;                             /* Let us leave the event loop */
  57. }
  58.  
  59.  
  60.  
  61. /*
  62.     doAboutItem
  63.     
  64.     Handles the "About Aware..." menu item.  It uses AlertWindow to
  65.     put up a dialog box with one button (labelled Continue).  It also
  66.     has one substitution string used for making the date/time (the
  67.     configuration data) part of the message.
  68. */
  69. void doAboutItem()
  70. {
  71.     char *substr[10];       /* Array of pointers to substitution strings */
  72.     
  73.     substr[0] = asciiTime;                  /* First string is asciiTime */
  74.     AlertWindow(refIsResource * 2, substr, 1L);
  75. }
  76.  
  77.  
  78.  
  79. /*
  80.     doMenu()
  81.     
  82.     This routine is called when a menu item is selected.  It determines
  83.     which item was picked and then calls the apropriate routine to
  84.     handle that item.
  85. */
  86. void doMenu()
  87. {
  88.     unsigned int    menuNum, itemNum;
  89.  
  90.     menuNum = HiWord (event.wmTaskData);    /* Find out which menu was selected */
  91.     itemNum = LoWord (event.wmTaskData);    /* Find out which item was selected */
  92.     
  93.     switch(itemNum) {
  94.         case AboutItem:                     /* "About Aware..." was picked */
  95.             doAboutItem();                  /* Handle the About item */
  96.             break;
  97.         case QuitItem:                      /* Quit was picked */
  98.             doQuitItem();                   /* Handle Quit item */
  99.             break;
  100.         case LoadConfigItem:                /* "Load Configuration" picked */
  101.             loadConfig();                   /* handle it */
  102.             break;
  103.         case SaveConfigItem:                /* "Save Configuration" picked */
  104.             saveConfig();                   /* handle it */
  105.             break;
  106.         case UndoItem:                      /* Handled by taskmaster */
  107.         case CutItem:                       /* Handled by taskmaster */
  108.         case CopyItem:                      /* Handled by taskmaster */
  109.         case PasteItem:                     /* Handled by taskmaster */
  110.         case ClearItem:                     /* Handled by taskmaster */
  111.             break;
  112.     }
  113.  
  114.     HiliteMenu(0, menuNum);                 /* Unhighlight the menu title. */
  115. }
  116.